-
Notifications
You must be signed in to change notification settings - Fork 7
Improve resilience and performance of do_bulk_inference #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In case of errors, the `InferenceClient.do_bulk_inference` method will now return `None` for the affected objects instead of aborting the entire bulk inference operation (and discarding any successfully processed objects). Fixes issue #68 The fix for #68 is different than what is described in #68. Instead of using a generator based approach which will require the SDK consumer to implement the error handling themselves, the SDK itself now handles the errors. The downside of not using a generator is a larger memory footprint to accumulate the results in a list. As an alternative, we can consider using a generator to either yield the successfully processed inference results or the list containing `None`. This approach will save memory. Additionally, this commit introduces parallel processing in `InferenceClient.do_bulk_inference`. This will greatly improve performance. Due to the non-lazy implementation of `ThreadPoolProcessor.map`, this increases memory usage slightly ([cpython issue #74028]) [cpython issue #74028]: python/cpython#74028
This also contains a documentation formatting fix.
This reverts commit 4372b8f.
setuptools must be installed much earlier in the process.
SreevishnuAB
approved these changes
Jun 17, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The bulk_inference code is now multithreaded. For this reason, the trick of returning different values in the Mock based on the order of the calls no longer works. This was somewhat accidentally working on CPython, but not on pypy.
264db6f
to
accc46b
Compare
This is mainly useful to fix the tests which rely on the mocks being called in a certain order. One of the tests supports concurrency by mocking in a better way, but this was not feasible for the other tests. This commit also updates the documentation build tools to the latest version to fix the documentation build on my local machine.
31da951
to
5bbf4a2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In case of errors, the
InferenceClient.do_bulk_inference
methodwill now return
None
for the affected objects instead of abortingthe entire bulk inference operation (and discarding any successfully
processed objects).
Fixes issue #68
The fix for #68 is different than what is described in #68. Instead of
using a generator based approach which will require the SDK consumer to
implement the error handling themselves, the SDK itself now handles the
errors. The downside of not using a generator is a larger memory footprint
to accumulate the results in a list. As an alternative, we can consider
using a generator to either yield the successfully processed inference
results or the list containing
None
. This approach will save memory.Additionally, this commit introduces parallel processing in
InferenceClient.do_bulk_inference
.This will greatly improve performance. Due to the non-lazy implementation of
ThreadPoolProcessor.map
, this increases memory usage slightly (cpython issue #74028)Checks: